<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>福利</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../css/auislide.css" />
    <link rel="stylesheet" type="text/css" href="../css/style1.css"/>
    <style>
        .empty{ text-align: center; padding: 120px 0; }
		.m_header_v2 {
			position: relative;
			z-index: 400
		}
		
		.m_header_v2 .m_header_bar {
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
			height: 44px;
			background-color: #fff;
			position: relative
		}
		
		.m_header_v2 .m_header_bar::after {
			content: "";
			position: absolute;
			z-index: 1;
			pointer-events: none;
			background-color: #e5e5e5;
			height: 1px;
			left: 0;
			right: 0;
			bottom: 0
		}
		@media only screen and (-webkit-min-device-pixel-ratio:2) {
			.m_header_v2 .m_header_bar::after {
				-webkit-transform: scaleY(.5);
				-webkit-transform-origin: 50% 100%
			}
		}
		
		.m_header_v2 .m_header_bar_title {
			height: 44px;
			line-height: 44px;
			font-size: 18px;
			color: #333;
			text-align: center;
			-webkit-box-flex: 1;
			-webkit-flex: 1;
			flex: 1;
			min-width: 0;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap
		}
		
		.m_header_v2 .m_header_bar_back {
			display: block;
			width: 44px;
			height: 44px;
			/* background: url() no-repeat 50%; */
			background-size: 20px 20px
		}
		
		.m_header_v2 .m_header_bar_menu {
			display: block;
			width: 44px;
			height: 44px;
			background: url() no-repeat 50%;
			background-size: 20px
		}
    </style>
</head>
<body>
	<div class="m_header_v2" style="display: block;">
		<div class="m_header_bar"style="background:linear-gradient(90deg, #1c304b 0%, #449b93 100%);">
			
			<div class="m_header_bar_title" style="color:#D4D4D4;font-size:20px;">福利中心</div>
		</div>
	</div>
	
<div class="aui-searchbar" id="search" style="background-color:#fff;">
    <div class="aui-searchbar-input aui-border-radius">
      <i class="aui-iconfont aui-icon-search"></i>
      <input type="text" placeholder="输入你需要优惠卷的商品名称" id="ff_wd">
    </div>
    <div class="aui-btn aui-btn-info aui-btn-block" tapmode onClick="toSearch()" style="width:50px;height:30px;line-height:30px;margin-right:5px;">搜索</div>
  </div>
  <div id="aui-slide"  class="fx-box">
    <div id="slidebox" class="aui-slide-wrap" style="margin: 5px;border-radius:0.5rem;box-shadow:0.1rem 0.1rem 0.4rem rgba(99, 99, 99, 0.3);" >

                      <!--顶部横幅未加载完成时的提示-->
                        <!--img id="bpic" src="../image/default_picture/default_banner.png"  onClick="UnloadedCompleted()">
                      <!--顶部横幅未加载完成时的提示-->
					    


    </div>
    <div class="aui-slide-page-wrap"><!--分页容器--></div>
  </div>

  <div class="list-title">
    <div class="list-title-l">
      <span style="color:#585858;font-size: 0.7rem"><i class="iconfont icon-zuirehotchunse" style="color:#ff7600;font-size: 0.8rem"></i>福利推荐</span>
    </div>

  </div>


  <section class="aui-grid aui-margin-b-15">
      <div class="aui-row" id="fl_list">

        <!--VIP 观影区未加载完成时的提示-->



            <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
            <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
            <div class="aui-grid-label">爱奇艺</div>
          </div>

          <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
          <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
          <div class="aui-grid-label">腾讯视频</div>
          </div>

          <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
          <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
          <div class="aui-grid-label">优酷视频</div>
          </div>

          <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
          <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
          <div class="aui-grid-label">搜狐视频</div>
          </div>

          <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
          <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
          <div class="aui-grid-label">芒果TV</div>
          </div>

          <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
          <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
          <div class="aui-grid-label">PPTV</div>
          </div>

          <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
          <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
          <div class="aui-grid-label">暴风影音</div>
          </div>

          <div class="aui-col-xs-3 pt-list" tapmode onClick="UnloadedCompleted()">
          <i class="aui-iconfont"><img src="../image/app/ico_loading.gif"/></i>
          <div class="aui-grid-label">M1905</div>
          </div>


        <!--VIP 观影区未加载完成时的提示-->


      </div>

  </section>

<!--
  <div class="fx-box" id="guanggao">

    <div class="fx-box-t">
      <img src="../image/default_picture/default_banner.png" style="margin: 10px;border-radius:0.5rem;box-shadow:0.1rem 0.1rem 0.4rem rgba(99, 99, 99, 0.3);"  tapmode onClick="UnloadedCompleted()">
    </div>
    <div class="br"></div>
    <div class="fx-box-t">
      <img src="../image/default_picture/default_banner.png" style="margin: 10px;border-radius:0.5rem;box-shadow:0.1rem 0.1rem 0.4rem rgba(99, 99, 99, 0.3);"  tapmode onClick="UnloadedCompleted()">
    </div>


  </div>
-->

  <div class="fx-box" id="guanggao">

          <div  class="aui-slide-wrap" style="margin: 10px;border-radius:0.5rem;box-shadow:0.1rem 0.1rem 0.4rem rgba(99, 99, 99, 0.3);" >

                            <!--顶部横幅未加载完成时的提示-->
                              <img id="bpic" src="../image/default_picture/default_banner.png"  onClick="UnloadedCompleted()">
                            <!--顶部横幅未加载完成时的提示-->

          </div>




          <div  class="aui-slide-wrap" style="margin: 10px;border-radius:0.5rem;box-shadow:0.1rem 0.1rem 0.4rem rgba(99, 99, 99, 0.3);" >

                            <!--顶部横幅未加载完成时的提示-->
                              <img id="bpic" src="../image/default_picture/default_banner.png"  onClick="UnloadedCompleted()">
                            <!--顶部横幅未加载完成时的提示-->
          </div>


</div>






  <div class="">

  </div>
</body>
<script type="text/x-dot-template" id="bannertpl">
  {{~ it.data : value : index }}
    <div class="aui-slide-node bg-dark" tapmode onclick="toBanner('{{= value. linkurl }}')">
        <img src="http://ys.6love.site/{{= value. picurl }}" />
    </div>
  {{~}}
</script>
<script type="text/x-dot-template" id="flicotpl">
  {{~ it.data : value : index }}
  		<div class="aui-col-xs-3 pt-list" tapmode onclick="toBanner('{{= value. linkurl }}')">
          <i class="aui-iconfont"><img src="http://ys.6love.site/{{= value. picurl }}"/></i>
          <div class="aui-grid-label">{{= value. name }}</div>
        </div>

  {{~}}
</script>
<script type="text/x-dot-template" id="guanggaotpl">
  {{~ it.data : value : index }}


  <div  class="aui-slide-wrap" style="margin: 10px;border-radius:0.5rem;box-shadow:0.1rem 0.1rem 0.4rem rgba(99, 99, 99, 0.3);" >

                      <img  src="http://ys.6love.site/{{= value. picurl }}"  tapmode onclick="toBanner('{{= value. linkurl }}')">

  </div>

  {{~}}
</script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.js"></script>
<script type="text/javascript" src="../script/auipullrefresh.js"></script>
<script type="text/javascript" src="../script/auislide.js"></script>
<script type="text/javascript" src="../script/auilazyload.js" ></script>
<script type="text/javascript">

//alert(localStorage.getItem('fxpic1'));
  var slide = new auiSlide({
      container:document.getElementById("aui-slide"),
      // "width":300,
  //    "height":200,
      "speed":300,
      "pageShow":true,
      "autoPlay": 5000,
      "pageStyle":'dot',
      "loop":true,
      'dotPosition':'center',
  });
  new auiLazyload({
      errorImage:'../image/error-img.jpg'
  });
  var api_url = localStorage.getItem('api_url');
  apiready = function(){




    //下拉刷新
        api.setCustomRefreshHeaderInfo({
            bgColor : '#fff',
             images: [
                  'widget://image/app/xiala/1.png',
                  'widget://image/app/xiala/2.png',
                  'widget://image/app/xiala/3.png',
                  'widget://image/app/xiala/4.png',
                  'widget://image/app/xiala/5.png',
                  'widget://image/app/xiala/6.png',
                  'widget://image/app/xiala/7.png',
                  'widget://image/app/xiala/8.png',
                    ],
                    tips: {
                        pull: '下拉刷新！',
                        threshold: '松开立即刷新！',
                        load: '正在刷新'
                    }

        }, function() {
			getNav();
            //下拉刷新被触发，自动进入加载状态，使用 api.refreshHeaderLoadDone() 手动结束加载中状态
            setTimeout(function(){
        api.refreshHeaderLoadDone()
            }, 3000);
        });
        //下拉刷新




//获取信息
    api.parseTapmode();

	getNav();
  }



///////广告图片 和小图标广告 点击访问 方法    imgUrl   S   ///////
/*  function imgUrl(img){
    if (img=='img1') {
      api.openWin({
          name: 'h5',
          url: './h5.html',
          pageParam: {
              url: localStorage.getItem('fxurl1')
          }
      });
    }else {
      api.openWin({
          name: 'h5',
          url: './h5.html',
          pageParam: {
              url: img
          }
      });
    }

  }*/

//// ↑ ↑ ↑ ↑ ↑原方法  ↑ ↑ ↑ ↑ ↑////
function imgUrl(url){



      if (url == '') {


        api.toast({
            msg: '(#^.^#) 暂无详情'
        });

      }else {


        //网络连接判断S


                            api.ajax({
                                url: api_url+'/login/login/banben.html',
                                method: 'get'
                            },function(ret, err){
                                if (ret) {

                                             //网络正常   跳转





                                                   /*
                                                   api.showProgress({
                                                       title: 'VIP登录中',
                                                       modal: false
                                                   });
                                             */
                                             api.toast({
                                                 msg: '加载中'
                                             });



                                             api.openWin({
                                                 name: 'h5',
                                                 url: './h5.html',
                                                 pageParam: {
                                                     url: url
                                                 }
                                             });





                                } else {

                                            //网络连接失败 进行提示
                                            NetworkConnectionFailurePrompt();

              }


          });
    //网络连接判断E

      }



}
///////广告图片 和小图标广告 点击访问 方法    imgUrl   E   ///////



///////访问轮播地址 方法    toBanner   S   ///////
function toBanner(url){

  if (url == '') {


    api.toast({
        msg: '(#^.^#) 暂无详情'
    });

  }else {


    //网络连接判断S


                        api.ajax({
                            url: api_url+'/login/login/banben.html',
                            method: 'get'
                        },function(ret, err){
                            if (ret) {

                                         //网络正常   跳转





                                               /*
                                               api.showProgress({
                                                   title: 'VIP登录中',
                                                   modal: false
                                               });
                                         */
                                         api.toast({
                                             msg: '加载中'
                                         });



                                               api.openWin({
                                                   name: 'h5',
                                                   url: './h5.html',
                                                   pageParam: {
                                                       url: url
                                                   }
                                               });




                            } else {

                                        //网络连接失败 进行提示
                                        NetworkConnectionFailurePrompt();

          }


      });
//网络连接判断E

  }
}

///////访问轮播地址 方法    toBanner   E   ///////


////////会员项目打开方法  s  ////////
  function openWin(name){
    var time = localStorage.getItem('user_time');
    var user_id = localStorage.getItem('user_id');
    var username = localStorage.getItem('user_name');
    var timestamp = Date.parse(new Date())/1000;
    if (user_id!=0) {
      api.alert({
          title: '请先登录',
          msg: '知道了',
      });
      return;
    }

    if (time > timestamp) {
      api.openWin({
          name: ''+name+'',
          url: ''+name+'.html',
          bounces:false,
          delay: 300
      });
    }else if (time == -1) {
      api.openWin({
          name: ''+name+'',
          url: ''+name+'.html',
          bounces:false,
          delay: 300
      });
    }else if (time < timestamp) {
      alert('到期啦~官人先开个VIP哟');
      api.openWin({
          name: 'open_vip_win',
          url: './open_vip_win.html',
      });
    }

  }
////////会员项目打开方法  E  ////////


//////////////////////    幻灯轮播图获取  方法  banNer  S  //////////////////////
  function banNer(){
    var slide = new auiSlide({
        container:document.getElementById("aui-slide"),
        // "width":300,
        "height":150,
        "speed":300,
        "pageShow":true,
        "autoPlay": 5000,
        "pageStyle":'dot',
        "loop":true,
        'dotPosition':'center',
    });
  }

//////////////////////    幻灯轮播图获取  方法  banNer  E  //////////////////////



//////////////////////    轮播图获取  方法  getNav  S  //////////////////////
  function getNav(){
    var flid = $api.byId('fl_list');
    var fltpl = $api.byId('flicotpl');
	var bannerid = $api.byId('slidebox');
    var bannertpl = $api.byId('bannertpl');

    var guanggaoid = $api.byId('guanggao');
    var guanggaotpl = $api.byId('guanggaotpl');
	
	// 添加广告	
    var uid = 0;
	if (localStorage.getItem('user_id')>1) {
        uid = localStorage.getItem('user_id');
    }
	// end
    api.ajax({
        url: api_url+'/app/nav/fl?uid='+uid,
        method: 'get',
    },function(ret, err){
        if (ret) {
          //渲染模板
          var pagefn = doT.template(fltpl.text);
          flid.innerHTML = pagefn(ret.tu);
          var pagefn = doT.template(bannertpl.text);
          bannerid.innerHTML = pagefn(ret.banner);
          var pagefn = doT.template(guanggaotpl.text);
          guanggaoid.innerHTML = pagefn(ret.guanggao);
           banNer();
//        alert( JSON.stringify( ret.banner ) );


        } else {
          /*
            alert( '网络错误' );
            api.hideProgress();
            */
        }
    });
  }

//////////////////////    轮播图获取  方法  getNav  E  //////////////////////



//优惠卷搜索方法
function toSearch(){
      var sys = api.systemType;
      var myval = document.getElementById('ff_wd').value;
      // alert(myval);
      // alert(112);

      var time = localStorage.getItem('user_time');
      var timestamp = Date.parse(new Date())/1000;
      var user_id = localStorage.getItem('user_id');
      var username = localStorage.getItem('user_name');
      if(user_id<1){
        /*新提示*/
        api.toast({
            msg: '亲爱的，你还没有登录哦！',
            duration: 5000
        });
        api.openWin({
            name: 'login',
            url: './login.html',
            delay: 2000
        });
        return;

      }
      if (time>timestamp||time==-1) {

            api.openWin({
                name: 'h5',
                url: './h5.html',
                pageParam: {
                    url: 'http://lgw.9t3g.cn/index.php?input=2&r=l&kw='+myval
                }
            });

      }else {
        VipExpiredHint();
      }

    }
//优惠卷搜索方法


  //////////////////////   打开APP时 获取Banner和图标  方法    DataLoading    定时     S //////////////////////

  //定时执行数据加载
  var timer = setInterval(function(){
      DataLoading();
  },1000)

  //判断是否服务器通信成功
  function DataLoading() {

    api.ajax({
        url: api_url+'/login/login/banben.html',
        method: 'get'
    },function(ret, err){
        if (ret) {

          getNav();    //获取Nav
          //alert( JSON.stringify( ret ) );
/*  关闭提示
          api.toast({
              msg: '数据已更新',
              duration: 1000
          });
*/

clearInterval(timer); // 获取成功 清除定时器
        } /*else {
          api.toast({
              msg: '数据获取成功 当前为最新数据',
              duration: 1000
          });

            //alert( JSON.stringify( err ) );
        }
        */
    });




  }

  //////////////////////   打开APP时 获取Banner和图标  方法    DataLoading    定时     E //////////////////////










////////////未加载完成时点击按钮提示 方法   UnloadedCompleted   S   ////////////

function UnloadedCompleted(){

      api.toast({
          msg: '加载失败 请检查网络是否顺畅'
      });
}

////////////未加载完成时点击按钮提示 方法   UnloadedCompleted   E   ////////////


////////////手动开始下拉刷新的加载状态 方法  fnRefreshHeaderLoading   S   ////////////
    function fnRefreshHeaderLoading() {
        api.refreshHeaderLoading();
    };
////////////手动开始下拉刷新的加载状态 方法  fnRefreshHeaderLoading   E   ////////////



</script>





</html>
